Copyright>        OpenRadioss
Copyright>        Copyright (C) 1986-2024 Altair Engineering Inc.
Copyright>
Copyright>        This program is free software: you can redistribute it and/or modify
Copyright>        it under the terms of the GNU Affero General Public License as published by
Copyright>        the Free Software Foundation, either version 3 of the License, or
Copyright>        (at your option) any later version.
Copyright>
Copyright>        This program is distributed in the hope that it will be useful,
Copyright>        but WITHOUT ANY WARRANTY; without even the implied warranty of
Copyright>        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Copyright>        GNU Affero General Public License for more details.
Copyright>
Copyright>        You should have received a copy of the GNU Affero General Public License
Copyright>        along with this program.  If not, see <https://www.gnu.org/licenses/>.
Copyright>
Copyright>
Copyright>        Commercial Alternative: Altair Radioss Software
Copyright>
Copyright>        As an alternative to this open-source version, Altair also offers Altair Radioss
Copyright>        software under a commercial license.  Contact Altair to discuss further if the
Copyright>        commercial version may interest you: https://www.altair.com/radioss/.
Chd|====================================================================
Chd|  DSECCNT                       source/output/anim/dseccnt.F  
Chd|-- called by -----------
Chd|        GENANI1                       source/output/anim/genani1.F  
Chd|-- calls ---------------
Chd|====================================================================
      SUBROUTINE DSECCNT(NESCT,NERWL,NESBW,NSTRF,
     2                   RWBUF,NPRW,NNWL,IXS)
C-----------------------------------------------
C   I m p l i c i t   T y p e s
C-----------------------------------------------
#include      "implicit_f.inc"
C-----------------------------------------------
C   C o m m o n   B l o c k s
C-----------------------------------------------
#include      "param_c.inc"
#include      "com04_c.inc"
C-----------------------------------------------
C   D u m m y   A r g u m e n t s
C-----------------------------------------------
      my_real
     .  RWBUF(NRWLP,*)
      INTEGER NESCT,NERWL,NESBW,NNWL,
     .        NSTRF(*),NPRW(*),IXS(NIXS,*)
C-----------------------------------------------
C   L o c a l   V a r i a b l e s
C-----------------------------------------------
      INTEGER J, I, K, K1, N, NSEG, N1, N2, N3, N4,NSEGC, NSEGTG,
     .    ITYP, KK,ITMP, K0, K5, K9
      my_real
     .   XX1, YY1, ZZ1, XX2, YY2, ZZ2, XX3, YY3, ZZ3,
     .   XX4, YY4, ZZ4, D13, XXC, YYC, ZZC
      INTEGER NSEGS, POWER2(8),IPACK,
     .         II(8), N5, N6, N7, N8, K3
      DATA POWER2/1,2,4,8,16,32,64,128/
C-----------------------------------------------
      IF (NSECT>0) THEN
        K0 = NSTRF(25)
        DO I=1,NSECT
          K5=K0+30+NSTRF(K0+14)+NSTRF(K0+6)
     1         + 2*NSTRF(K0+7) +NSTRF(K0+8)*2
          NSEGC = NSTRF(K0+9)
          DO J=1,NSEGC
            KK = K5+2*(J-1)+1
            IF(NSTRF(KK)/=0) NESCT = NESCT + 1
          ENDDO
          K9=K5+2*NSTRF(K0+9) +2*NSTRF(K0+10)
     1         +2*NSTRF(K0+11)+2*NSTRF(K0+12)
          NSEGTG = NSTRF(K0+13)
          DO J=1,NSEGTG
            KK = K9+2*(J-1)+1
            IF(NSTRF(KK)/=0) NESCT = NESCT + 1
          ENDDO
          K3=K0+30+NSTRF(K0+14)+NSTRF(K0+6)
          NSEGS=NSTRF(K0+7)

          IF(NSEGS/=0) NESCT = NESCT + 1

          DO J=1,NSEGS
            KK=K3+2*(J-1)
            IPACK=NSTRF(KK+1)
            IF(IPACK/=0)THEN
              N =NSTRF(KK)
              II(1)=IXS(2,N)
              II(2)=IXS(3,N)
              II(3)=IXS(4,N)
              II(4)=IXS(5,N)
              II(5)=IXS(6,N)
              II(6)=IXS(7,N)
              II(7)=IXS(8,N)
              II(8)=IXS(9,N)
              IF(     II(2)==II(1).AND.II(4)==II(3)
     .           .AND.II(8)==II(5).AND.II(7)==II(6))THEN
                N1=MOD(IPACK/POWER2(1),2)
                N2=MOD(IPACK/POWER2(3),2)
                N3=MOD(IPACK/POWER2(5),2)
                N4=MOD(IPACK/POWER2(6),2)
                IF(N1/=0.AND.N2/=0.AND.N3/=0)
     .             NESCT = NESCT + 1
                IF(N1/=0.AND.N2/=0.AND.N4/=0)
     .             NESCT = NESCT + 1
                IF(N2/=0.AND.N3/=0.AND.N4/=0)
     .             NESCT = NESCT + 1
                IF(N3/=0.AND.N1/=0.AND.N4/=0)
     .             NESCT = NESCT + 1
              ELSE
                N1=MOD(IPACK/POWER2(1),2)
                N2=MOD(IPACK/POWER2(2),2)
                N3=MOD(IPACK/POWER2(3),2)
                N4=MOD(IPACK/POWER2(4),2)
                N5=MOD(IPACK/POWER2(5),2)
                N6=MOD(IPACK/POWER2(6),2)
                N7=MOD(IPACK/POWER2(7),2)
                N8=MOD(IPACK/POWER2(8),2)
                IF(N1/=0.AND.N2/=0.AND.N3/=0.AND.N4/=0)
     .             NESCT = NESCT + 1
                IF(N5/=0.AND.N6/=0.AND.N7/=0.AND.N8/=0)
     .             NESCT = NESCT + 1
                IF(N1/=0.AND.N5/=0.AND.N6/=0.AND.N2/=0)
     .             NESCT = NESCT + 1
                IF(N4/=0.AND.N8/=0.AND.N7/=0.AND.N3/=0)
     .             NESCT = NESCT + 1
                IF(N1/=0.AND.N4/=0.AND.N8/=0.AND.N5/=0)
     .             NESCT = NESCT + 1
                IF(N2/=0.AND.N3/=0.AND.N7/=0.AND.N6/=0)
     .             NESCT = NESCT + 1
              END IF
            END IF
          END DO
          K0=NSTRF(K0+24)
        ENDDO
      ENDIF
C
      K=1
      DO N=1,NRWALL
         N2=N +NRWALL
         N3=N2+NRWALL
         N4=N3+NRWALL
         ITYP= NPRW(N4)

         IF(IABS(ITYP)==1)THEN
            NERWL = NERWL + 1 + 1
            NNWL = NNWL + 4
         ELSEIF(ITYP==2)THEN
            NERWL = NERWL + 24 + 1
            NNWL = NNWL + 48
         ELSEIF(ITYP==3)THEN
            NERWL = NERWL + 216 + 1
            NNWL = NNWL + 294
         ELSEIF(ITYP==4)THEN
            NERWL = NERWL + 1 + 1
            NNWL = NNWL + 4
         ENDIF
         K=K+NPRW(N)
         IF(NPRW(N4)==-1)K=K+NINT(RWBUF(8,N))
      ENDDO
C
      NESBW = NESCT + NERWL
C
      RETURN
      END
